package com.ruoyi.aftersale.controller;

import com.ruoyi.aftersale.domain.DmsTechnicalSupport;
import com.ruoyi.aftersale.service.IDmsTechnicalSupportService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 技术支援管理Controller
 * 
 * @author liuchuanfa
 * @date 2024-03-16
 */
@RestController
@RequestMapping("/aftersale/support")
public class DmsTechnicalSupportController extends BaseController
{
    @Autowired
    private IDmsTechnicalSupportService dmsTechnicalSupportService;

    /**
     * 查询技术支援管理列表
     */
    @PreAuthorize("@ss.hasPermi('aftersale:support:list')")
    @GetMapping("/list")
    public TableDataInfo list(DmsTechnicalSupport dmsTechnicalSupport)
    {
        startPage();
        List<DmsTechnicalSupport> list = dmsTechnicalSupportService.selectDmsTechnicalSupportList(dmsTechnicalSupport);
        return getDataTable(list);
    }

    /**
     * 导出技术支援管理列表
     */
    @PreAuthorize("@ss.hasPermi('aftersale:support:export')")
    @Log(title = "技术支援管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DmsTechnicalSupport dmsTechnicalSupport)
    {
        List<DmsTechnicalSupport> list = dmsTechnicalSupportService.selectDmsTechnicalSupportList(dmsTechnicalSupport);
        ExcelUtil<DmsTechnicalSupport> util = new ExcelUtil<DmsTechnicalSupport>(DmsTechnicalSupport.class);
        util.exportExcel(response, list, "技术支援管理数据");
    }

    /**
     * 获取技术支援管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('aftersale:support:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(dmsTechnicalSupportService.selectDmsTechnicalSupportById(id));
    }

    /**
     * 新增技术支援管理
     */
    @PreAuthorize("@ss.hasPermi('aftersale:support:add')")
    @Log(title = "技术支援管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DmsTechnicalSupport dmsTechnicalSupport)
    {
        return toAjax(dmsTechnicalSupportService.insertDmsTechnicalSupport(dmsTechnicalSupport));
    }

    /**
     * 修改技术支援管理
     */
    @PreAuthorize("@ss.hasPermi('aftersale:support:edit')")
    @Log(title = "技术支援管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DmsTechnicalSupport dmsTechnicalSupport)
    {
        return toAjax(dmsTechnicalSupportService.updateDmsTechnicalSupport(dmsTechnicalSupport));
    }

    /**
     * 删除技术支援管理
     */
    @PreAuthorize("@ss.hasPermi('aftersale:support:remove')")
    @Log(title = "技术支援管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(dmsTechnicalSupportService.deleteDmsTechnicalSupportByIds(ids));
    }
}
